home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Rockwell Fax1&ARA&Data < prev    next >
Text File  |  1994-11-04  |  8KB  |  422 lines

  1. ! Version 3.0
  2. !
  3. !$ Use this script with Rockwell-based (Supra, Xeba, Zoom, Hayes Optima, etc)
  4. !$ data/fax modems.
  5. !$ Supports: fax, ARA and regular data incoming calls.
  6. !
  7. !$ Make sure that *Class 1* fax software is installed
  8. !
  9. !$ A cable for hardware handshaking is required
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  12. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^5 Port Speed:        = Enum("9600","19200","38400","57600") "19200"
  15. ^6 Handshake wires:   = Bool("Both"="&D0","CTS only"="&D2") "&D2"
  16. ^7 Fax Port Speed:      = Bool("Fixed"="F","Auto"="V") "V"
  17. ! ------------------------------------------
  18. ! Resetting the modem:
  19. ! ------------------------------------------
  20. @Hangup
  21.   SetTries 2
  22.   Flush
  23.   HsReset 0,0,17,19,0,0
  24.   DtrSet
  25. !
  26. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  27. ! to enter the command mode
  28. !
  29. @Label 1
  30.   matchclr
  31.   matchstr 1 2 "OK¥r¥n"
  32.   write "ATH0&F¥r"
  33.   matchread 20
  34.   ChrDelay 1
  35.   Write "+++"
  36.   ChrDelay 0
  37.   DtrClear
  38.   SBreak
  39.   DtrSet
  40. !
  41.   DecTries
  42.   IfTries 0 1
  43. !
  44. ! OSErr -6019 "Modem error - the modem is not responding"
  45. !
  46.   exit -6019
  47. @Label 2
  48.   write "AT+FCLASS=0¥r"
  49.   Jsr 100
  50.   write "AT+FAE=0¥r"
  51.   Jsr 100
  52.   exit 0
  53.  
  54. ! ------------------------------------------
  55. !    Receiving incoming calls
  56. ! ------------------------------------------
  57. @ANSWER
  58. !
  59. ! Set the modem preferred speed first
  60. !
  61.   SerReset Val("^5"),0,8,1
  62.   Jsr 80
  63.  
  64. @Label 10
  65. !
  66. ! Set the common options
  67.   Jsr 70
  68. !
  69. ! Set the communication options:
  70. ! ・ &Q6: Normal connection (for ARA)
  71. ! ・ &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  72. ! ・ W1:  report connection speed
  73. !
  74.   Write "AT&Q6&K3W1¥r"
  75.   Jsr 100
  76. !
  77. ! Set Fax mode
  78. !
  79.   Write "AT+FCLASS=1¥r"
  80.   Jsr 100
  81.   Write "AT+FAE=1¥r"
  82.   Jsr 100
  83. !
  84. ! It's for Rockwell ONLY! Set FCLASS to 0 again - otherwise,
  85. ! it cannot accept data calls
  86. !
  87.   Write "AT+FCLASS=0¥r"
  88.   Jsr 100
  89. !
  90. ! Tell the modem to determine the type of the incoming call
  91. ! Fetch the tube after ^4 rings
  92. !
  93.   Write "ATS0=^4V0¥r"
  94.   Jsr 110
  95. !
  96. ! Everything is ready - let's sit and wait for a call
  97. ! We'll wait for 2 minutes, then reinitiate the modem
  98. !
  99.   Note "Waiting for a fax/ARA/data callノ"
  100.   MatchClr
  101.   matchstr 02 40 "47¥r"
  102.   MatchStr 03 41 "48¥r"
  103.   MatchStr 04 42 "49¥r"
  104.   MatchStr 05 43 "50¥r"
  105.   MatchStr 06 44 "51¥r"
  106.   MatchStr 07 45 "52¥r"
  107.   MatchStr 08 46 "53¥r"
  108.   MatchStr 09 47 "54¥r"
  109.   MatchStr 10 48 "55¥r"
  110.   MatchStr 11 49 "56¥r"
  111.   MatchStr 12 50 "57¥r"
  112.   MatchStr 13 51 "58¥r"
  113.  
  114.   MatchStr 15 19 "33¥r"
  115.   matchstr 16 18 "2¥r"
  116.   matchstr 17 57 "1¥r"
  117.   matchstr 18 17 "3¥r"
  118.   matchstr 19 17 "8¥r"
  119.   matchstr 20 17 "7¥r"
  120. @Label 16
  121.   Matchread 1200
  122. @Label 17
  123.   Note "Tuning againノ"
  124.   Write "ATV1¥r"
  125.   Jsr 100
  126.   Jump 10
  127. @Label 18
  128.   Note "Ringノ"
  129.   jump 16
  130. @Label 19
  131.   Note "Fax tones detectedノ"
  132.   IfStr 7 16 "V"
  133.   SetSpeed 19200
  134.   Jump 16
  135.  
  136. !
  137. ! Data connection has been established (we read "CONNECT")
  138. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  139. ! if it was an incoming call, put the "RING" before the "CONNECT"
  140. !
  141. @Label 20
  142.   IfOpen "Data" 21
  143.   Jump 30
  144. @Label 21
  145.   IfOpen "ARA" 22
  146.   Jump 35
  147. @Label 22
  148.   Note "Waiting for an ARA frame"
  149.   MatchClr
  150.   MatchStr 1 23 "^$¥r"
  151.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  152.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  153.   MatchRead 60
  154.   Jump 24
  155. @Label 23
  156.   QueueInput "^$¥r"
  157. @Label 24
  158.   Note "Non-ARA call"
  159.   Jump 35
  160.  
  161. @Label 28
  162.   Note "ARA 1.0 call"
  163.   Jump 30
  164. @Label 29
  165.   Note "ARA 2.0 call"
  166.   Jump 30
  167.  
  168. @Label 30
  169.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  170.   QueueInput "¥r¥nRING¥r¥n"
  171.   Attach "ARA" (DTR)
  172.  
  173. @Label 35
  174.   GetSReg C "DATA" 4
  175.   QueueInput "¥r^CCONNECT ^B¥r^C"
  176.   ifOriginate 36
  177.   QueueInput "¥r^CRING¥r^C"
  178. @Label 36
  179.   Attach "Data" (DTR,Escape,Break)
  180.  
  181.  
  182. !
  183. ! Converting numeric responses into the verbal
  184. !
  185. @Label 40
  186.   SetVar B "2400"
  187.   Jump 20
  188. @Label 41
  189.   SetVar B "4800"
  190.   Jump 20
  191. @Label 42
  192.   SetVar B "7200"
  193.   Jump 20
  194. @Label 43
  195.   SetVar B "9600"
  196.   Jump 20
  197. @Label 44
  198.   SetVar B "12000"
  199.   Jump 20
  200. @Label 45
  201.   SetVar B "14400"
  202.   Jump 20
  203. @Label 46
  204.   SetVar B "16800"
  205.   Jump 20
  206. @Label 47
  207.   SetVar B "19200"
  208.   Jump 20
  209. @Label 48
  210.   SetVar B "21600"
  211.   Jump 20
  212. @Label 49
  213.   SetVar B "24000"
  214.   Jump 20
  215. @Label 50
  216.   SetVar B "26400"
  217.   Jump 20
  218. @Label 51
  219.   SetVar B "28800"
  220.   Jump 20
  221.  
  222. ! ------------------------------------------
  223. ! Originating a call through the "ARA" subport
  224. ! ------------------------------------------
  225. @ORIGINATE "ARA"
  226.   SerReset Val("^5"),0,8,1
  227.   Jsr 80
  228. !
  229. ! Set the common options
  230. !
  231.   Jsr 70
  232. !
  233. ! Set the Data mode:
  234. ! ・ &Q6:Normal connection (no compression, correction - for ARA)
  235. ! ・ &K3: HW Handshake
  236. ! ・ハS7:  time-out (90 sec) for long-distance call (if you use them)
  237. ! ・ W1:  report connection rate
  238. !
  239.   Write "AT&Q6&K3S7=90W1¥r"
  240.   Jsr 100
  241. !
  242. ! Emit the ARA script commands ("Xnn")
  243.   Jsr 60
  244. !
  245. ! Prepare to receive all error result codes, dial the number
  246. !
  247.   Jsr 90
  248.   MatchStr 1 55 "¥r¥nCARRIER "
  249.   MatchRead 1000
  250.   Write "¥r"
  251.   Exit -6019
  252. @Label 55
  253.   QueueInput "¥r¥nCARRIER "
  254.   Attach "ARA" (DTR)
  255.  
  256. ! ------------------------------------------
  257. ! Originating a call through the "DATA" subport
  258. ! ------------------------------------------
  259. @ORIGINATE "Data"
  260.   SerReset Val("^5"),0,8,1
  261.   Jsr 80
  262. !
  263. ! Set the common options
  264. !
  265.   Jsr 70
  266. !
  267. ! Set the Data mode:
  268. ! ・ ¥N3: Auto-reliable
  269. ! ・ &K3: HW Handshake
  270. ! ・ハS7:  time-out (90 sec) for long-distance call (if you use them)
  271. !
  272.   Write "AT&K3S7=90¥r"
  273.   Jsr 100
  274. !
  275. ! Emit the Data commands
  276.   Jsr 60
  277. !
  278. ! Prepare to receive all error result codes, dial the number
  279. !
  280.   Jsr 90
  281.   MatchStr 1 56 "¥r¥nCONNECT "
  282.   MatchRead 1000
  283.   Write "¥r"
  284.   Exit -6019
  285. @Label 56
  286.   QueueInput "¥r¥nCONNECT "
  287.   Attach "Data" (DTR,Escape,Break)
  288.  
  289. ! ------------------------------------------
  290. ! Originating a call through the "Fax" subPort
  291. ! ------------------------------------------
  292. @ORIGINATE "Fax"
  293. !
  294. ! Set the "Fax" speed
  295. !
  296.   SerReset 19200,0,8,1
  297.   Jsr 80
  298. !
  299. ! Set the common options
  300. !
  301.   Jsr 70
  302. !
  303. ! Set the Fax mode
  304. ! &K4: Xon/Xoff handshake
  305. ! &S0: DSR always on (see above)
  306. !
  307.   Write "AT&S0&K4+FCLASS=1¥r"
  308.   Jsr 100
  309. !
  310. ! Now emit all commands that the application has sent to that port,
  311. ! except "FCLASS", etc
  312. !
  313.   EmitClear "+FCLASS","V","E"
  314.   Jsr 60
  315.   Write "ATV0¥r"
  316.   Jsr 110
  317. !
  318. ! Prepare to receive all error result codes, dial the number
  319. !
  320.   MatchClr
  321.   MatchStr 01 57 "1¥r"
  322.   MatchStr 13 93 "3¥r"
  323.   MatchStr 14 94 "8¥r"
  324.   MatchStr 15 92 "7¥r"
  325.   Write "ATD^1¥r"
  326.   HsReset *
  327.   MatchRead 900
  328.   Write "¥r"
  329.   Exit -6019
  330.  
  331. !
  332. ! Fax connection has been established (we read "FAX")
  333. ! Put the +FCON back to the buffer,
  334. ! if it was an incoming call, put the "RING" before the "+FCON"
  335. ! Attach the "Fax" subPort
  336. !
  337. @Label 57
  338.   QueueInput "1¥r"
  339.   IfStr 7 58 "V"
  340.   SetSpeed 19200
  341. @Label 58
  342.   ifOriginate 59
  343.   QueueInput "2¥r2¥r"
  344. @Label 59
  345.   Attach "Fax" (Reset(2400),IdleLimit=30)
  346.  
  347. !
  348. ! This section emits all modem commands sent from the client application
  349. ! For each set of commands the "OK" answer is awaited
  350. !
  351. @Label 60
  352.   EmitStart
  353. @Label 61
  354.   EmitCommand 62
  355.   Jsr 100
  356.   Jump 61
  357. @Label 62
  358.   return
  359. !
  360. ! This section initiates the modem before ANSWER and ORIGINATEs:
  361. ! extended responses + connect at the highest rate + speaker control +
  362. ! reset on Dtr drop + DCD valid
  363. ! Verbal responses mode, no echo 
  364. !
  365. @Label 70
  366.   Write "ATX4N1M^2L^3^6&C1V1E0¥r"
  367.   Jsr 100
  368.   return 
  369.  
  370. !
  371. ! This section syncronize the modem after the serial port speed switching
  372. !
  373. @Label 80
  374.   ChrDelay 1
  375.   Write "AT¥r"
  376.   ChrDelay 0
  377.   Jsr 100
  378.   return
  379. !
  380. ! Prepare to receive error result codes, send the dialing command and
  381. ! set the user's handshake mode
  382. !
  383. @Label 90
  384.   MatchClr
  385.   MatchStr 2 91 "NO DIALTONE¥r¥n"
  386.   MatchStr 3 92 "BUSY¥r¥n"
  387.   MatchStr 4 93 "NO CARRIER¥r¥n"
  388.   MatchStr 5 94 "NO ANSWER¥r¥n"
  389.   Write "ATD^1¥r"
  390.   HsReset *
  391.   return
  392. @Label 91
  393.   exit -6020
  394. @Label 92
  395.   exit -6022
  396. @Label 93
  397.   exit -6021
  398. @Label 94
  399.   exit -6023
  400. !
  401. ! Processing the AT command:
  402. ! OK -> proceed
  403. ! ERROR or TimeOut ->exit -6019
  404. ! It can be called AFTER the "Write" command, since LineShare buffers input
  405. !
  406. @Label 100
  407.   MatchClr
  408.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  409.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  410. @Label 101
  411.   MatchRead 20
  412. @Label 102
  413.   Exit -6019
  414. @Label 103
  415.   return
  416.  
  417. @Label 110
  418.   MatchClr
  419.   MatchStr 1 103 "0¥r"
  420.   MatchStr 2 102 "4¥r"
  421.   Jump 101
  422.